import os
import argparse
import threading
from generate_video import main_process as get_summary
import multiprocessing

def get_config():
    parser = argparse.ArgumentParser()
    # Generate summary videos
    parser.add_argument('--root_path', type=str, default='')
    parser.add_argument('--save_path', type=str, default='./summary_videos')
    parser.add_argument('--weight_path', type=str, default='./weights/SumMe/split4.pt')
    parser.add_argument('--num_works', type=int, default=1)

    kwargs = vars(parser.parse_args())

    return kwargs

def get_subdirectories(path):
    directories = []
    for entry in os.listdir(path):
        entry_path = os.path.join(path, entry)
        if os.path.isdir(entry_path):
            directories.append(entry_path)
    return directories


def run(task_list, save_path, weight_path):
    for task in task_list:
        get_summary(os.path.join(save_path, ('/').join(task.split('/')[-2:])), task, weight_path)


def main():
    config = get_config()
    root_path = config['root_path']
    save_path = config['save_path']
    num_works = config['num_works']
    weight_path = config['weight_path']
    dirs = get_subdirectories(root_path)
    
    for dir in dirs:
        date_dir = get_subdirectories(dir)
        for task in date_dir:
            get_summary(os.path.join(save_path, ('/').join(task.split('/')[-2:])), task, weight_path)

if __name__ == '__main__':
    main()




